home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / src / fft / hc_unpack.c < prev    next >
Encoding:
Text File  |  2001-05-14  |  2.7 KB  |  91 lines

  1. /* fft/hc_unpack.c
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. int
  21. FUNCTION(gsl_fft_halfcomplex,unpack) (const BASE halfcomplex_coefficient[],
  22.                       BASE complex_coefficient[],
  23.                       const size_t stride, const size_t n)
  24. {
  25.   size_t i;
  26.  
  27.   if (n == 0)
  28.     {
  29.       GSL_ERROR ("length n must be positive integer", GSL_EDOM);
  30.     }
  31.  
  32.   REAL(complex_coefficient,stride,0) = halfcomplex_coefficient[0];
  33.   IMAG(complex_coefficient,stride,0) = 0.0;
  34.  
  35.   for (i = 1; i < n - i; i++)
  36.     {
  37.       const ATOMIC hc_real = halfcomplex_coefficient[(2 * i - 1) * stride];
  38.       const ATOMIC hc_imag = halfcomplex_coefficient[2 * i * stride];
  39.  
  40.       REAL(complex_coefficient,stride,i) = hc_real;
  41.       IMAG(complex_coefficient,stride,i) = hc_imag;
  42.       REAL(complex_coefficient,stride,n - i) = hc_real;
  43.       IMAG(complex_coefficient,stride,n - i) = -hc_imag;
  44.     }
  45.  
  46.   if (i == n - i)
  47.     {
  48.       REAL(complex_coefficient,stride,i) = halfcomplex_coefficient[(n - 1) * stride];
  49.       IMAG(complex_coefficient,stride,i) = 0.0;
  50.     }
  51.  
  52.   return 0;
  53. }
  54.  
  55.  
  56. int
  57. FUNCTION(gsl_fft_halfcomplex,radix2_unpack) (const BASE halfcomplex_coefficient[],
  58.                          BASE complex_coefficient[],
  59.                          const size_t stride, const size_t n)
  60. {
  61.   size_t i;
  62.  
  63.   if (n == 0)
  64.     {
  65.       GSL_ERROR ("length n must be positive integer", GSL_EDOM);
  66.     }
  67.  
  68.   REAL(complex_coefficient,stride,0) = halfcomplex_coefficient[0];
  69.   IMAG(complex_coefficient,stride,0) = 0.0;
  70.  
  71.   for (i = 1; i < n - i; i++)
  72.     {
  73.       const ATOMIC hc_real = halfcomplex_coefficient[i * stride];
  74.       const ATOMIC hc_imag = halfcomplex_coefficient[(n - i) * stride];
  75.  
  76.       REAL(complex_coefficient,stride,i) = hc_real;
  77.       IMAG(complex_coefficient,stride,i) = hc_imag;
  78.       REAL(complex_coefficient,stride,n - i) = hc_real;
  79.       IMAG(complex_coefficient,stride,n - i) = -hc_imag;
  80.     }
  81.  
  82.   if (i == n - i)
  83.     {
  84.       REAL(complex_coefficient,stride,i) = halfcomplex_coefficient[i * stride];
  85.       IMAG(complex_coefficient,stride,i) = 0.0;
  86.     }
  87.  
  88.   return 0;
  89. }
  90.  
  91.